// 分组背包
#include <bits/stdc++.h>
using namespace std;

const int N = 110;
int n, m;
int v[N][N], w[N][N], s[N];
int f[N];

int main()
{
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        for (int j = 0; j < s[i]; j ++) {
            cin >> v[i][j] >> w[i][j];
        }
    }
    // 遍历不同组
    for (int i = 1; i <= n; i++ ) {
        // 遍历所有体积
        for (int j = m; j >= 0; j--) {
            // 每一种物品选k个的价值
            for (int k = 0; k < s[i]; k ++) {
                if (v[i][k] <= j) 
                    f[j] = max(f[j], f[j - v[i][k]] + w[i][k]);
            }
        }
    }
    
    cout << f[m] << endl;
    return 0;
}